interface MsgObj {
  currentPart?: number;
  totalPart?: number;
  content: string;
  contentType: 'html' | 'text';
  signature?: string;
}

const cache: string[] = [];
function setContent(msg: MsgObj) {
  if (!msg.totalPart) {
    msg.totalPart = 1;
  }
  if (!msg.currentPart) {
    msg.currentPart = 1;
  }
  if (msg.currentPart === 1) {
    cache.splice(0, cache.length);
  }
  cache.push(msg.content);
  if (msg.totalPart === msg.currentPart) {
    const html = cache.join('');
    const editorFrame: HTMLIFrameElement = document.querySelector('.editor')!;
    const editorDocument = editorFrame.contentDocument;
    editorDocument!.body.innerHTML = html;
  }
}

function getHTML() {}
// @ts-ignore
declare const window: any;

// @ts-ignore
window.setContent = setContent;
// @ts-ignore
window.getHTML = getHTML();
